package crontab

import (
	"longmen/server/internal/services/worker/internal"

	"github.com/robfig/cron/v3"
)

// Start .
func CrontabInit() {

	c := cron.New()

	c.AddFunc("0 1 * * *", Check6t) // 6t充值检查每天凌晨1点运行 发放观赛券

	c.AddFunc("@every 30m", SyncPoint) // 腾讯赛事积分榜

	c.AddFunc("59 23 * * *", SyncAnchorLiveData) // 每日23点59分写入统计
	c.AddFunc("@every 1m", LiveCallback)
	//c.AddFunc("@every 1m", SyncExpert)//这里不要了0805
	c.AddFunc("@every 1m", SyncLives)

	c.AddFunc("5 0 * * *", DoCleanEsData)

	c.AddFunc("00 00 * * *", InitStatUserDaysRow) // 每日0点01分写入统计
	c.AddFunc("@every 2m", SyncTopUser)           // 达人榜更新
	c.AddFunc("00 00 * * *", SyncAnchor)          // 每日0点01分写入统计
	c.AddFunc("1 0 * * * ", DoStatistics)         // 统计
	c.AddFunc("@every 10m", ImStats)              // 统计
	c.AddFunc("@every 30s", OnlineDevice)         // 私聊上报的在线设备，写入到ES
	//c.AddFunc("@every 30s", room_event.SyncRoomStatusAndHeat) // 房间热度统计

	c.AddFunc("0 */1 * * *", internal.QueryDbGiftToMqOmit) //每一小时执行一次

	c.AddFunc("0 1 * * *", DelNotActiveConversationCache) //
	c.AddFunc("@every 1m", SendBackofficeMsg)             // 后台離線消息推送
	//c.AddFunc("@every 1m", SendMatchStartMsg)   // 關注比賽開賽通知

	//c.AddFunc("@every 30s", room_event.SyncRoomStatusAndHeat) // 房间热度统计
	c.AddFunc("@every 15m", CreateImRoom) // 為主播開立房間

	c.AddFunc("@every 30s", PutUserBloom)           // 將用戶加入布隆
	c.AddFunc("@every 30s", PutAnchorBloomIncrease) // 將主播加入布隆

	c.AddFunc("01 00 * * *", GenStatUserCheckinDaily) // 统计每日的签到记录数据, 每天0点1分
	c.AddFunc("02 00 * * *", GenStatUserLotteryDaily) // 统计每日的抽奖记录数据, 每天0点2分

	c.AddFunc("@every 10m", CronProcessPrivateChat) // 每10分钟处理超时私聊会话

	c.AddFunc("@every 2m", AutoLive) // 后台自动开播计划

	//c.AddFunc("5 0 * * * ", DeleteLiveRecord) // 删除N天前的直播录制

	c.AddFunc("@every 5m", LiveWatchStatSave) // 直播间观看时间入库

	c.AddFunc("@every 30m", SyncLiveRecordReply) // 回调缺失视频同步入库

	c.AddFunc("5 0 * * *", DeleteImRecord) // 删除两天前的im登陆记录

	c.Start()
	select {}
}
